package com.shengzai.mapreduce.groupby;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;

import java.io.IOException;

public class DriverGroupBy {
    public static void main(String[] args) throws IOException, InterruptedException, ClassNotFoundException {
        Configuration entries = new Configuration();
        Job job = Job.getInstance(entries);
        job.setJobName("GroupBy");
        job.setJarByClass(DriverGroupBy.class);

        job.setMapperClass(MapGroupBy.class);
        job.setReducerClass(ReduceGroupBy.class);

        job.setMapOutputKeyClass(Text.class);
        job.setMapOutputValueClass(Text.class);

        job.setOutputKeyClass(Text.class);
        job.setOutputValueClass(Text.class);

        FileOutputFormat.setOutputPath(job,new Path("hadoop_code/src/data/groupBy"));
        FileInputFormat.addInputPath(job,new Path("hadoop_code/src/data/StudentJoin/part-r-00000"));

        job.waitForCompletion(true);
    }
}
